package edu.hawaii.ics111.exam;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests the ExamQuestion class.
 * 
 * @author Branden Ogata
 *
 */

public class TestExamQuestion
{
  /**
   * Tests the methods of the ExamQuestion class.
   * 
   */
  
  @Test
  public void test()
  {
    ExamQuestion fillInTheBlank = new ExamQuestion(1, "What is the question?", 
                                             new String[] {"What is the answer?"}, 
                                             -1);
    ExamQuestion multipleChoice = new ExamQuestion(2, "Finish the phrase: \"To be or not to __\"",
                                                   new String[] {"A",
                                                                 "B",
                                                                 "C",
                                                                 "D"},
                                                   1);
    
    // Test getters
    assertEquals("Check getNumber", fillInTheBlank.getNumber(), 1);
    assertEquals("Check getQuestion", fillInTheBlank.getQuestion(), "What is the question?");
    assertTrue("Check getAnswers", ("A".equals(multipleChoice.getAnswers()[0])) &&
                                   ("B".equals(multipleChoice.getAnswers()[1])) &&
                                   ("C".equals(multipleChoice.getAnswers()[2])) &&
                                   ("D".equals(multipleChoice.getAnswers()[3])));
    assertEquals("Check getCorrect", multipleChoice.getCorrect(), 1);
    
    // Should technically test setters, but the program never actually uses any of the setters
    
    // Test other methods
    assertEquals("Check getCorrectAnswer with fill-in-the-blank", 
                 fillInTheBlank.getCorrectAnswer(), "What is the answer?");
    assertEquals("Check getCorrectAnswer with multiple-choice",
                 multipleChoice.getCorrectAnswer(), "B");
    assertTrue("Check isCorrect", fillInTheBlank.isCorrect("What is the answer?"));
  }

}
